<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'userList.jsp' starting page</title>
    <script type="text/javascript" src="${path}/js/public/grid.js"></script>
    <style type="text/css">
    	.linkActive{color:#ff9900;text-decoration:none;font-weight:bold;}
		.linkNoActive{color:#3399ff;}
    </style>
	<script type="text/javascript">
	
		$().ready(function(){
		   	
			addCss("0");
			doPost("0");
		});
		
		//0--待审批 1-已审批
		var viewArray = ["0","1"];
		
		function addCss(id){
			$.each( viewArray, function(n, i){
				if(i == id){
					$("#"+i).find("span").removeClass();
					$("#"+i).find("span").addClass("linkActive");
				}else {
					$("#"+i).find("span").removeClass();
					$("#"+i).find("span").addClass("linkNoActive");
				}
			});
		}
		
		var val;
		function doPost(status){
    		val = status;
			addCss(status);
			resetGrid(mygrid,"queryForm",{"low":status});
		}
	
  		function doExportStyle(){
			openDailog("view","${path}/jsp/drug/exportEdit.jsp?style=1",610,550,"药品出库",false,true,null,function(dlg){
  				
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		//此处的way 1标识的出库方式是药库
  		function doSet(){
			if(!isSelectOne(mygrid)){
				alert("请选择一条记录进行修改");
				return;
			}
			var record = mygrid.getSelectedRecords()[0];
			openDailog("view","${path}/jsp/drug/setDrug.jsp?id=" + record['id'] + "&value=1",500,150,"设置药品信息",false,true,null,function(dlg){
  				dlg.getIFrame().doSave();
  			});
  		}
  		
  		function doImport(){
  			dlg = new Dialog("viewSheet");
			dlg.Width = 500;
			dlg.Height = 150;
			dlg.Title = "数据导入";
			dlg.URL = "${path}/jsp/drug/drugExcelImport.jsp";
			dlg.ShowMessageRow = true;
			dlg.ShowButtonRow = false;
			dlg.addParam("window", window);
			dlg.MessageTitle = "<b>从Excel文件导入数据</b>"; 
			dlg.Message = "<font color='red'>Excel中的列数必须与表的列数一致</font>，并且数据项从第2行开始，第1行为表头。<br>选中文件之后即自动上传、导入";
			dlg.show();
  		}
  		
  		function doQuery(){
  			resetGrid(mygrid,"queryForm",{"low":val});
  		}
  		
  		function doQueryHistory(){
			openDailog("view","${path}/jsp/drug/ykUseHistory.jsp?place=1",800,400,"变动历史",false,true,null);
  		}
  		
	</script>
  </head>
  
  <body>
  
  	<table cellSpacing="0" cellPadding="0" style="width:100%;height:100%;" border="0">
  		<tr>
			<td class="windowTitle">药品管理  &gt; 药库管理</td>
		</tr>
		
  		<tr id="">
  			<td style="height:35px;width:100%" class="windowHead">	
	  			<form id="queryForm">
					<table cellSpacing="0" cellPadding="0" width="100%" height="100%" border="0" >
						<tr>
							<td>
								<img alt="view" src="../../images/menu/view.png" height="18px" width="20px" align="top"></img>
								<font style="font-weight:bold;">&nbsp;视图：</font>&nbsp;&nbsp;
								<a id="0" href="javascript:doPost('0')" ><span>药品信息</span></a>&nbsp;&nbsp;&nbsp;&nbsp;
								<a id="1" href="javascript:doPost('1')" ><span>低库存药品</span></a>&nbsp;&nbsp;&nbsp;&nbsp;
							</td>
						</tr>
						<tr>
							<td>
								药名：<input name="search_CONTAIN_name" id="drugName" class="textbox" style="width: 220px" />&nbsp;&nbsp;&nbsp;&nbsp;
								<ui:Button type="query" onclick="doQuery()">查询</ui:Button>&nbsp;&nbsp;&nbsp;&nbsp;
							</td>
						</tr>
						<tr>
							<td>	
								<ui:Permission value="drugLibrary_set">
									<ui:Button type="edit" onclick="doSet()">设置</ui:Button>
								</ui:Permission>
								<ui:Permission value="drugLibrary_out">
									<ui:Button onclick="doExportStyle()"><img src="${path}/images/drug/export.png">出库</ui:Button>
								</ui:Permission>
								<ui:Permission value="drugLibrary_enter">
									<ui:Button onclick="doImport()"><img src="${path}/images/drug/drugImport.png">入库</ui:Button>
								</ui:Permission>
								<ui:Permission value="drugLibrary_changeHistory">
									<ui:Button onclick="doQueryHistory()"><img src="${path}/images/drug/useHistory.png">变动历史</ui:Button>
								</ui:Permission>
							</td>
						</tr>
					</table>
				</form>
				<br/>
				<a style="text-decoration: none;"></a>
			</td>
		</tr>
		
		<tr>
			<td style="width:100%;height:100%;overflow:hidden"  class="windowBody">
				<div id="mess_box" style="width:100%;height:100%;overflow:hidden">
					<ui:Grid id="mygrid" css="width:100%;height:100%"
				    		 onCellClicked="selectedSingleRow2"
				    		 dataProvider="com.system.provider.DrugListProvider:getData" parameters='"value":"1","campus":"${currentUserCampus}"'>
				    	<ui:GridField name="id" header="ID" isChecked="true" align="center"/>
				    	<ui:GridField name="name" header="药品名称" align="left" width="20%"/>
				    	<ui:GridField name="vender" header="生产厂商" align="left" width="22%"/>
				    	<ui:GridField name="spec" header="规格" align="center" width="10%"/>
				    	<ui:GridField name="unit" header="单位" align="center" width="10%"/>
				    	<ui:GridField name="supply_price" header="售价" align="center" width="10%"/>
				    	<ui:GridField name="drug_num" header="库存" align="center" width="10%"/>
				    	<ui:GridField name="batch_number_valid" header="批号有效期" align="center" width="15%"/>
			    	</ui:Grid>
		    	</div>
		    </td>
		</tr>
  	</table>
  	
  	<script type="text/javascript">
		$().ready(function(){
			disableSelectAll(mygrid);
		});
	</script>
  </body>
</html>
